package cn.com.hori.cms.config;

import cn.com.hori.cms.dao.TokenRepository;
import cn.com.hori.cms.interceptor.ManageTokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 刘艺
 * @date 2018/3/8 15:01
 */
@Configuration
@EnableWebMvc
public class BeansConfig implements WebMvcConfigurer {

    /**
     * Token Repo
     */
    @Autowired
    private TokenRepository tokenRepository;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加 拦截器 白名单
//        registry.addInterceptor(new ManageTokenInterceptor(tokenRepository)).excludePathPatterns(
//                "/smc/manager/loginSubmit"
//        );
//
//        // 添加 拦截器 黑名单
//        registry.addInterceptor(new ManageTokenInterceptor(tokenRepository)).addPathPatterns(
//                "/smc/*"
//        );
    }
}
